from sqlalchemy import BigInteger, String, DECIMAL, Column, DateTime

from config.database import Base


class Settlement(Base):
    """
    交易交割记录表
    """

    __tablename__ = 'stock_trade_settlement'
    __table_args__ = {'comment': '交易交割记录表'}

    id = Column(BigInteger, primary_key=True, autoincrement=True, nullable=False, comment='主键ID')
    account_no = Column(String(64), nullable=True, comment='所属证券账号')
    trade_date = Column(DateTime, nullable=True, comment='成交日期')
    trade_time = Column(String(10), nullable=True, comment='成交时间')
    stock_code = Column(String(20), nullable=True, comment='证券代码')
    stock_name = Column(String(100), nullable=True, comment='证券名称')
    operation = Column(String(100), nullable=True, comment='操作')
    trade_quantity = Column(DECIMAL, nullable=True, comment='成交数量')
    trade_no = Column(String(50), nullable=True, comment='成交编号')
    average_price = Column(DECIMAL, nullable=True, comment='成交均价')
    trade_amount = Column(DECIMAL, nullable=True, comment='成交金额')
    balance = Column(DECIMAL, nullable=True, comment='余额')
    occurred_amount = Column(DECIMAL, nullable=True, comment='发生金额')
    commission = Column(DECIMAL, nullable=True, comment='手续费')
    stamp_duty = Column(DECIMAL, nullable=True, comment='印花税')
    other_fees = Column(DECIMAL, nullable=True, comment='其他杂费')
    current_amount = Column(DECIMAL, nullable=True, comment='本次金额')
    contract_no = Column(String(50), nullable=True, comment='合同编号')
    regulatory_fee = Column(DECIMAL, nullable=True, comment='证管费')
    handling_fee = Column(DECIMAL, nullable=True, comment='经手费')
    other_charges = Column(DECIMAL, nullable=True, comment='其他费用')
    exchange = Column(String(20), nullable=True, comment='交易市场')
    total_fees = Column(DECIMAL, nullable=True, comment='费用合计')
    create_time = Column(DateTime, nullable=True, comment='创建时间')
    update_time = Column(DateTime, nullable=True, comment='更新时间')
